<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>遍历</title>
</head>
<body>

<%--遍历打印1~10--%>
<c:forEach begin="1" end="10" step="1" var="x">
    ${x} <br>
</c:forEach>


<%--遍历集合--%>

<%
    List<String> list = new ArrayList<>();
    list.add("aaa");
    list.add("bbb");
    list.add("ccc");
    list.add("ddd");

    request.setAttribute("ls",list);


%>

<c:forEach items="${ls}" var="s">
    ${s}
</c:forEach>

</body>
</html>
